<template>
  <headPage :tabsIndex="2"></headPage>
  <div class="view_list main_box" v-loading="loading">
    <div
      class="list_item"
      v-for="(item, index) in newsList"
      :key="index"
      @click="goDetails(item.aid)"
    >
      <div class="item_le">
        <div class="item_icon"></div>
        <div class="item_text">
          {{ item.dongtaibiaoti }}
        </div>
      </div>
      <div class="item_ri">{{ item.create_time }}</div>
    </div>
    <div class="no_data" v-if="newsList.length == 0 && !loading">
      <img class="no_img" src="../../assets/default/12.png" alt="" />
    </div>
  </div>

  <div class="paging_content">
    <paging
      :total="total"
      :pageSize="pageSize"
      @pageChange="pageChange"
    ></paging>
  </div>
  <footerPage></footerPage>
</template>

<script setup name="news">
import { post65e5b17771686 } from "@/utils/api.js";
import { ref, reactive, onMounted } from "vue";
import { useRouter } from "vue-router";
let router = useRouter();
import headPage from "@/components/headPage.vue";
import footerPage from "@/components/footerPage.vue";
import paging from "@/components/paging.vue";

function goDetails(aid) {
  router.push({
    path: "/newsDetails",
    query: {
      aid: aid,
    },
  });
}
onMounted(() => {
  getList();
});
let newsList = reactive([]);
let total = ref(0);
let loading = ref(true);
let pageNum = ref(1);
let pageSize = ref(10);
function getList() {
  post65e5b17771686({
    page: pageNum.value,
    list_rows: pageSize.value,
  }).then((res) => {
    // console.log(res);
    loading.value = false;
    if (res.code == 1) {
      total.value = res.data.total;
      newsList = res.data.data;
    }
  });
}
// 分页
function pageChange(page) {
  pageNum.value = page;
  loading.value = true;
  getList();
}
</script>

<style lang="scss" scoped>
.view_list {
  margin-top: 110px;
  background: #fff;
  padding: 8px 14px;
  min-height: 300px;
  .list_item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    cursor: pointer;
    .item_le {
      display: flex;
      align-items: center;
      .item_icon {
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: #1f52ae;
        margin-right: 7px;
      }
      .item_text {
        font-size: 9px;
      }
    }
    .item_ri {
      font-size: 9px;
      color: #999;
    }
  }
}
.paging_content {
  margin-bottom: 24px;
}
</style>
